<template id="grid-template">
<div class="col-md-12 col-sm-12 button-group" v-if="buttons.add">
	<button class="btn btn-default btn-lg btn-add"
		@click="showView('add','')">添加{{rescName}}</button>
</div>
<form class="search" v-if="search">
	搜索 <input name="query" v-model="searchQuery">
</form>
<table class="table grid">
	<thead>
		<tr>
			<th>#</th>
			<th v-for="key in columns" @click="sortBy(key)"
				:class="{active: sortKey == key}">{{headers[$index]}} <span
				class="arrow" :class="sortOrders[key]>0?'asc':'dsc'"></span>
			</th>
			<th class="op"></th>
		</tr>
	</thead>
	<tbody>
		<tr
			v-for="entry in data | filterBy searchQuery | orderBy sortKey sortOrders[sortKey]"
			@click="rowSelected(entry[major],$index)"
			:class="{'tr-selected':selected[$index]}">
			<td>{{$index+1}}</td>
			<td v-for="key in columns">{{entry[key]}}</td>
			<td>
				<button class="btn btn-sm btn-default"
					@click="showView('edit',entry[major])" v-if="buttons.edit">编辑</button>
				<button class="btn btn-sm btn-danger"
					@click="showView('delete',entry[major])" v-if="buttons.delete">删除</button>
			</td>
		</tr>
	</tbody>
</table>
<div class="tfoot">共{{data.length}}条记录</div>
</template>